package com.taotao.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.common.pojo.EUDataGridResult;
import com.taotao.common.pojo.TaotaoResult;
import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemParamItem;
import com.taotao.service.IItemCatService;
import com.taotao.service.IItemDescService;
import com.taotao.service.IItemService;

/**
 * 商品控制器
 * 
 * @author Administrator
 *
 */
@Controller
@RequestMapping(value = "/item")
public class ItemController {
	@Autowired
	private IItemService itemService;

	/**
	 * 通过id查询商品信息
	 * 
	 * @param itemId
	 * @return
	 */
	@RequestMapping(value = "/{itemId}")
	@ResponseBody
	public TbItem getItemById(@PathVariable Long itemId) {
		TbItem tbItem = this.itemService.getItemById(itemId);
		return tbItem;
	}

	/**
	 * 通过id查询商品信息
	 * 
	 * @param itemId
	 * @return
	 */
	@RequestMapping(value = "/list")
	@ResponseBody
	public EUDataGridResult list(Integer page, Integer rows) {
		return this.itemService.getItemList(page, rows);
	}

	/**
	 * 保存商品信息
	 * 
	 * @param page
	 * @param rows
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/save")
	@ResponseBody
	public TaotaoResult saveItem(TbItem item, String desc, String itemParams)
			throws Exception {
		TaotaoResult taotaoResult = this.itemService.saveItem(item, desc,
				itemParams);
		return taotaoResult;
	}
}
